//
//  InformationViewController.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/8/20.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit
import XLPagerTabStrip

@objc protocol InformationDelegate {
    @objc optional func changeScrollHeight(height:CGFloat) //改变滑动高度
    @objc optional func updateTitle() //刷新标题
}
 
class InformationViewController: InformationPageViewController {

    weak var InformationDelegate : InformationDelegate?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }

    //MARK: 更多标签
    override func moreLabel() {
        let dataArray = [todayHeadlines,featuredFavourites,littleWhiteRaiders,useCardRaiders,quotaStrategy,creditCardEvaluation,popularWool,exclusiveRecommendation,specialReport,newCardExpress,bankInformation]
        
        let moreLabelVC = MoreLabelViewController.init(dataArray: dataArray)
        moreLabelVC.labelBlock = {(index) in
            self.moveToViewController(at: index.row, animated: true) //切换至选择标签
        }
        self.present(moreLabelVC, animated: false, completion: nil)
    }
    

    //MARK: 滑动的子控制
    override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
        
        let titleArray = [todayHeadlines,featuredFavourites,littleWhiteRaiders,useCardRaiders,quotaStrategy,creditCardEvaluation,popularWool,exclusiveRecommendation,specialReport,newCardExpress,bankInformation]
        let urlArray = ["9","0","10","11","12","13","14","16","17","18","19"]
        
        var viewControllers = [UIViewController]()
        
        for i in 0..<titleArray.count {
            let newsVC = NewsViewController.init(urlString: urlArray[i])
            newsVC.delegate = self
            newsVC.itemInfo.title = titleArray[i]
            viewControllers.append(newsVC)
        }
        
        return viewControllers
    }
    
}

extension InformationViewController : NewsDelegate {
    
    //MARK: 刷新标题
    func updateTitle() {
        
        self.InformationDelegate?.updateTitle!()
    }
    
    //MARK: 改变坐标
    func changeScrollHeight(height: CGFloat) {
        self.InformationDelegate?.changeScrollHeight!(height: height)
    }
    
}
